﻿@using Shop.Tools

@{
    Layout = null;
    var sysMsg = TempData["sysMsg"];
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>系统登录</title>
    <link href="/css/login.css" rel="stylesheet" asp-append-version="true" />
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css"/>
</head>
<body>
    @if (sysMsg != null && !sysMsg.ToString().IsNullOrEmpty())
    {
        <div class="alert">@sysMsg</div>
    }
    <div class="login-main">
        <div class="font-weight-bold text-center login-add">系统登录</div>
        <div>
            <div class="login-main-lpic"></div>
            <div class="login-main-rform">
                @using (Html.BeginForm("Login", "Login", new { ReturnUrl = ViewData["ReturnUrl"] }, FormMethod.Post, true, new { id = "fnLogin" }))
                {
                    @Html.AntiForgeryToken()
                    <input type="hidden" id="vCode" name="vCode" value="" />
                    <div class="form-group">
                        <label for="account">账号：</label>
                        <input type="text" name="account" id="account" class="form-control" value="@ViewData["Account"]" autocomplete="off" placeholder="请输入账号" pattern="\w+" oninput="setCustomValidity('');" oninvalid="setCustomValidity('请检查账号');" required="required" title="账号必填" />
                    </div>
                    <div class="form-group">
                        <label for="pwd">密码：</label>
                        <input type="password" name="pwd" id="pwd" class="form-control" value="" autocomplete="off" placeholder="请输入密码" pattern="\w+" oninput="setCustomValidity('');" oninvalid="setCustomValidity('请检查密码');" required="required" title="密码必填" />
                    </div>
                    <div class="form-group">
                        <label for="checkCode">验证码：</label>
                        <div class="row">
                            <div class="col-6"><input class="form-control" type="text" value="" autocomplete="off" id="checkCode" oninput="setCustomValidity('');" name="checkCode" maxlength="4" pattern="\w{4}" placeholder="请输入验证码" title="验证码必填" oninvalid="setCustomValidity('请检查验证码');" required="required" /></div>
                            <div class="col-6"><img class="form-control" src="data:image/jpeg;base64,@ViewData["checkCode"]" alt="点击获取验证码" id="imgCode" name="imgCode" title="点击获取验证码" /></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="remindMe"><input type="checkbox" value="0" name="remindMe" id="remindMe" />记住账号</label>
                    </div>
                    <div class="form-group">
                        <div class="row">
                            <div class="col-12 text-center">
                                <button type="submit" class="btn btn-primary" style="width: 50%">登 录</button>
                            </div>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    <script src="/lib/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#imgCode").click(function() {
                var that = this;
                $.get({
                    url: '@Url.Action("GetCode")?_id=' + Math.random(),
                    data: {},
                    success: function(r) {
                        that.src = r.data.img;
                        $("#vCode").val(r.data.vCode);
                    }
                });
            });
            $("#imgCode").click();
        });
    </script>
</body>
</html>
